export const loadAndProcessData = () =>
  Promise.all([
    d3.tsv('../50m.tsv'),
    d3.json('../50m.json')
  ]).then (([tsvData, jsonData]) => {
      
    //使用reduce()
    const rowById = tsvData.reduce((accumulator, d)=>{
      accumulator[d.iso_n3] = d;
      return accumulator;
    },{});


    const countries = topojson.feature(jsonData, jsonData.objects.countries);
    countries.features.forEach(d => {
      Object.assign(d.properties, rowById[d.id]);
      
    });
    return countries;
  });